//
//  WXPCommonAgreementView.m
//  全局的底部的隐私政策按钮
//
//  Created by wxp on 2025/2/25.
//

#import "WXPCommonAgreementView.h"

@implementation WXPCommonAgreementView

#pragma mark - lazy
- (UILabel *)labelTitle{
    if (_labelTitle == nil) {
        _labelTitle = [UILabel new];
        [GlobalMethod setLabel:_labelTitle widthLimit:0 fontNum:12 textColor:COLOR_LIGHT_GRAY text:@"《Política de privacidad 》"];
    }
    return _labelTitle;
}
- (UIButton *)btnAgree{
    if (!_btnAgree) {
        _btnAgree = [UIButton new];
        _btnAgree.backgroundColor = [UIColor clearColor];
        _btnAgree.tag = 1;
        [_btnAgree addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _btnAgree;
}

#pragma mark - init
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.widthHeight = XY(SCREEN_WIDTH, 0);
        self.backgroundColor = [UIColor clearColor];
        [self addSubView];
    }
    return self;
}

- (void)addSubView{
    [self addSubview:self.labelTitle];
    [self addSubview:self.btnAgree];
    [self resetView];
}

#pragma mark - 点击事件
- (void)btnClick:(UIButton *)sender{
    [NSObject clickFeedback];
    [self.labelTitle addClickAnimate];
    switch (sender.tag) {
        case 1:
        {
            [Global_Nav pushVCName:@"WXPPrivacyAgreementVC" animated:true];
        }
            break;
        default:
            break;
    }
}

#pragma mark - 刷新View
- (void)resetView{
    self.btnAgree.widthHeight = XY(self.labelTitle.width+26, self.labelTitle.height+20);
    self.btnAgree.centerXTop = XY(self.width/2, 0);
    self.labelTitle.centerXCenterY = XY(self.btnAgree.centerX, self.btnAgree.centerY);
    self.height = self.btnAgree.height;
}

@end
